import { Controller } from 'egg';

export default class HomeController extends Controller {
  public async index() {
    const { ctx } = this;
    await ctx.render('index.html');
  }
  public async getPerson(ctx) {
    ctx.body = await ctx.service.getinfo.getPerson('杭州');
  }
  public async getJoke(ctx) {
    ctx.body = await ctx.service.getinfo.getJoke();
  }

  public async login(ctx) {
    ctx.body = await ctx.service.login.login();
  }

  public async callback(ctx) {
    ctx.body = await ctx.service.login.loginCallBack(ctx);
  }

  public async getUserInfo(ctx) {
    ctx.body = await ctx.service.login.getUserInfo(ctx);
  }

  public async getUser(ctx) {
    ctx.body = await ctx.model.User.find({});
  }

  public async addUser(ctx) {
    ctx.body = await ctx.service.login.addUser(ctx);
  }
}
